package com.longdaji.decoration.widget;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.widget.TextView;

import com.longdaji.decoration.R;

/**
 * 自定义可操作性dialog
 * Created by JiajiXu on 17-12-11.
 */

public class CustomOperateDialog extends BubbleDialog implements View.OnClickListener {
    private ViewHolder mViewHolder;
    private OnClickCustomButtonListener mListener;

    public CustomOperateDialog(Context context) {
        super(context);
        calBar(true);
        setTransParentBackground();
        setPosition(Position.BOTTOM);
        View rootView = LayoutInflater.from(context).inflate(R.layout.pop_window_bubble, null);
        mViewHolder = new ViewHolder(rootView);
        addContentView(rootView);
        mViewHolder.news.setOnClickListener(this);
        mViewHolder.home.setOnClickListener(this);
        mViewHolder.collect.setOnClickListener(this);
    }

    @Override
    public void onClick(View v) {
        if (mListener != null) {
            mListener.onClick(v.getId());
        }
    }

    private static class ViewHolder {
        TextView news, home, collect;

        public ViewHolder(View rootView) {
            news = rootView.findViewById(R.id.tv_news);
            home = rootView.findViewById(R.id.tv_home);
            collect = rootView.findViewById(R.id.tv_collect);
        }
    }

    public void setClickListener(OnClickCustomButtonListener l) {
        this.mListener = l;
    }

    public interface OnClickCustomButtonListener {
        void onClick(int id);
    }
}
